#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "data/gsdata.h"
#include "plugins/gsplugin.h"
#include "workspace.h"
#include "manager/importdatadialog.h"
#include "manager/datamanagerwidget.h"
#include "manager/variablesviewwidget.h"
#include "manager/resultlogdialog.h"
#include "manager/scriptdialog.h"

#include <QMainWindow>
#include <QLayout>
#include <QString>
#include <QTabWidget>
#include <QList>
#include <QDockWidget>
#include <QInputDialog>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(const QList<GSPlugIn*> plugins, QWidget *parent = 0);
    ~MainWindow();
    void keyPressEvent(QKeyEvent *e);
    bool isDataDuplicates(QString name);
    bool isDataDuplicates(GSData* inData);
    bool getVaildName(QString* newName);

private:
    void setupToolBar();
    void setupMenuBar();
    void setupWorkSpace();
    void setupDockWidget();
    void setFileView(int id);
    void setupPlugIns(const QList<GSPlugIn*> plugins);

protected:
    void closeEvent(QCloseEvent* event);

signals:
    void dataUpdated(QList<GSData*>* pDataSet);
    void deleteDataview(QString newName);

public slots:
    void newWorkSpace();
    void aboutGSSP();
    void aboutAuthor();
    void newPlot();
    void importData();
    void exportData();
    void deleteData(int index);
    void dockWidgetChange();
    void closeWorkSpace(int index);    
    void setPlotLayout();
    void updateView(int idx);
    void fullScreen();
    void exitFullScreen();
    void openTutorials();
    void hideAllWindow();
    void appendData(GSData inData);
    void duplicateVariable(GSData* pdata);
    void renameVariable(GSData* pdata);

private:
    Ui::MainWindow* ui;
    QTabWidget* dockWorkSpace = NULL;
    DataManagerWidget* dataManagerWidget = NULL;
    VariablesViewWidget* variablesViewWidget = NULL;
    ResultLogDialog* resultLogDialog = NULL;
    ScriptDialog* scriptDialog = NULL;

    QInputDialog* inputDialog = NULL;

    QString name; //project name
    QString comments; //comments about this project

    QList<WorkSpace*> workSpace;
    QList<GSPlugIn*> plugInSet; //store plugin applications

public:
    QList<GSData*> dataSet; //store the imported datas
    QList<QAction*> menuSet;
};
#endif // MAINWINDOW_H
